<?php
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/config.inc.php');
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/top.inc.php');
?>

<?php

$instructor_id = mysql_real_escape_string(strip_tags($_POST['iid']));
$q = "SELECT * FROM instructors WHERE id = '$instructor_id'";
$r = mysql_query($q);
$row = mysql_fetch_assoc($r);
$instructor_fname = $row['first_name'];
$instructor_lname = $row['last_name'];
$availability_id = mysql_real_escape_string(strip_tags($_POST['id']));

echo "<h1>Delete Timeslot for ".stripslashes($instructor_fname)." ".stripslashes($instructor_lname)."</h1>";

//initialize variables used to connect to database
$db = "scheduler";
$user = "root";
$pass = "";

//connect to database
mysql_connect("localhost", $user, $pass);
@mysql_select_db($db);

$query = "DELETE FROM instructor_availability WHERE id='$availability_id'";
$result = mysql_query($query);

if ($result)
{
	echo "Timeslot has been successfully deleted!";
	echo "<br />";
}
else
{
	echo "Timeslot was NOT able to be deleted at this time!";
	echo "<br />";
}

//close
mysql_close();

echo "<p>";
	echo "<a href='update_availability.php?id=$instructor_id&fname=$instructor_fname&lname=$instructor_lname'>&lt;&lt; Back to Instructors Portal</a><br />";
echo "</p>";
?>

<?php
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/bottom.inc.php');
?>